<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>viewproject</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="robots" content="all,follow">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" href="vendor/font-awesome/css/font-awesome.min.css">
    <!-- Fontastic Custom icon font-->
    <link rel="stylesheet" href="css/fontastic.css">
  
    <!-- theme stylesheet-->
    <link rel="stylesheet" href="css/style.default.css" id="theme-stylesheet">
    <!-- Custom stylesheet - for your changes-->
    <link rel="stylesheet" href="css/custom.css">
    <!-- Favicon-->
    <link rel="shortcut icon" href="img/favicon.ico">
    <!-- Tweaks for older IEs--><!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script><![endif]-->
  </head>
  <body>
    <div class="page">
     
        
      <div class="page-content d-flex align-items-stretch"> 
        <!-- Side Navbar -->
       
        <div class="content-inner" style="width: 100%;">
          <!-- Page Header-->
         
          <!-- Forms Section-->
          <section class="forms no-padding-top"> 
            <div class="container-fluid">
              <div class="row">
              
                <!-- Form Elements -->
                <div class="col-lg-12" >
                  <div class="card" >
                    <div class="card-close">
                      <div class="dropdown">
                        <button type="button" id="closeCard5" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-toggle"><i class="fa fa-ellipsis-v"></i></button>
                        <div aria-labelledby="closeCard5" class="dropdown-menu dropdown-menu-right has-shadow"><a href="#" class="dropdown-item remove"> <i class="fa fa-times"></i>Close</a><a href="#" class="dropdown-item edit"> <i class="fa fa-gear"></i>Edit</a></div>
                      </div>
                    </div>
                    <div class="card-header d-flex align-items-center">
                      <h3 class="h4">查看项目</h3>
                    </div>
                    <div class="card-body">
                      <form class="form-horizontal">
                        <div class="form-group row no-padding-bottom">
                          <label class="col-sm-3 form-control-label">项目名称</label>
                          <div class="col-sm-9">
                            <span type="text" name="proejctName" id="projectName" class="form-control" ></span>
                          </div>
                        </div>
                        <div class="form-group row no-padding-bottom">
                          <label class="col-sm-3 form-control-label">项目类型</label>
                          <div class="col-sm-9">
                            <span name="isremoved" id="isremoved" class="form-control mb-3">
                              
                            </span>
                          </div>
                        </div>
                        <div class="form-group row no-padding-bottom">
                          <label class="col-sm-3 form-control-label">项目经理</label>
                          <div class="col-sm-9">
                            <span name="manager" id="manager" class="form-control mb-3">
                             
                            </span>
                          </div>
                        </div>
                        <div class="line no-margin-top"></div>
                        <div class="form-group row no-padding-bottom">
                          <label class="col-sm-3 form-control-label">委托方</label>
                          <div class="col-sm-9">
                            <span type="text" name="customer" id="customer" class="form-control"></span>
                          </div>
                        </div>
                        <div class="form-group row" style="height: auto;">
                          <label class="col-sm-3 form-control-label">估价目的</label>
                          <div class="col-sm-9" style="height: auto;">
                           
                            <textarea class="form-control" rows="5" id="valuationPurpose" disabled="true" >
                            	
                            </textarea>
                            <small class="help-block-none">可拖拽右下角调整输入框大小.</small>
                          </div>
                        </div>
                        <div class="line"></div>
                        
                        <div class="form-group row">
                          <label class="col-sm-3 form-control-label h4">估值物</label>
                         
                        </div>
                        <div class="line no-margin-top"></div>
                        
                        
                        
	                        	<!-- 估值物信息-->
	                        	 <!-- Projects Section-->
          
            <div id="valuationBox" class="container-fluid projects no-padding-top no-padding-bottom">
             
              
              
            </div>
           
          
		                        <!-- 估值物信息-->
		                        
	                        
	                        
                        </div>
                        <div class="line"></div>
                        
                        
                        </div>
                      </form>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </section>
         
        </div>
      </div>
    </div>
    <!-- JavaScript files-->
    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="vendor/popper.js/umd/popper.min.js"> </script>
    <script src="vendor/bootstrap/js/bootstrap.min.js"></script>
    <script src="vendor/jquery.cookie/jquery.cookie.js"> </script>
    <script src="vendor/chart.js/Chart.min.js"></script>
    <script src="vendor/jquery-validation/jquery.validate.min.js"></script>
    <!-- Main File-->
    <script src="js/front.js"></script>
    <script type="text/javascript" src="js/getUrlParam.js" ></script>
    <script type="text/javascript">
    	//获取url中的参数  需引入 getUrlParam.js
    		var projectId=UrlParm.parm("projectId"); 
    		if(projectId==""||projectId == undefined){//若未取到项目编号 关闭此选项卡
    			parent.closeTab("查看项目");
                 
    		}else{
    			//拿到了传入的项目编号
    			$.ajax({
              type:"get",
              url:"/business.spr?method=queryProject",
              contentType:"application/json",
              dataType: "json",
              data:{
                  'projectId':projectId
             				},
              success:function(data){
                  var dataObj=eval("("+data+")");

                  if(dataObj.result!="0000"){
                      alert(dataObj.msg);
                  }else{
                  	 var dataObj=eval("("+data+")");

                  if(dataObj.result!="0000"){
                      alert(dataObj.msg);
                  }else{
                  	 $("#projectName").html(dataObj.params.projectInf.projectname);
    								 $("#isremoved").html(dataObj.params.projectInf.isremoved==1 ? "拆迁":"普通");
    								 $("#manager").html(dataObj.params.projectInf.managername);
    								 $("#customer").html(dataObj.params.projectInf.customer);
    								 $("#valuationPurpose").html(dataObj.params.projectInf.purpose);
    								var lands = dataObj.params.landInf;
    								var projectname = dataObj.params.projectInf.projectname;
    								var box = $('#valuationBox');
    								
    								
                   for(var i=0;i<lands.length;i++){
                   	var temp = '<div class="project">'+
                '<div class="row bg-white has-shadow">'+
                  '<div class="left-col col-lg-6 d-flex align-items-center justify-content-between">'+
                   ' <div class="project-title d-flex align-items-center">'+
                    '  <div class="image has-shadow"><img src="img/project-3.jpg" alt="..." class="img-fluid"></div>'+
                     ' <div class="text">'+
                      '  <h3 class="h4">'+getTitle(lands[i].position)+'</h3><small>'+projectname+'</small>'+
                      '</div>'+
                    '</div>'+
                    '<div class="project-date"><span class="hidden-sm-down"><i class="fa fa-clock-o"> &nbsp;&nbsp;&nbsp;</i>'+getItemType(lands[i].id)+'</span></div>'+
                  '</div>'+
                  '<div class="right-col col-lg-6 d-flex align-items-center">'+
                    '<div class="time"><i class="fa fa-list"></i>'+getJudgeStateCh(lands[i].objstatus)+' </div>'+
                    '<div class="project-progress">'+
                      '<div class="progress">'+getProgressBar(lands[i].objstatus)+
                      '</div>'+
                  '</div>'+
                  '<div class="col-lg-1"></div>'+
                   ' <div class="CTAs" objId="'+lands[i].id+'" >'+getButton()+
                    '</div>'+
                  '</div>'+
                '</div>'+
              '</div>';
                    
                    
              
              box.append(temp);
              
              //数据加载完成后 执行绑定按钮事件
              bindBtnEvent();
              
             }
                     
                  }
		
    			
                  	
		              }
                
		              
                  
              },
              error:function(){
              	
              	 alert("加载失败！");

              }
          });

    			
    		}
    		
    	//转义评估进度信息
    	// 0 保存 1 已提交 2 正在评估 3 评估完成待审核  4 审核驳回待修改 5 驳回修改中 6 完成
    	function getJudgeStateCh(state){
    		var inf = "";
    		switch(state){
    			case 1:
    						inf = "已提交";
    						break;
    			case 2:
    						inf = "评估中";
    						break;
    			case 3:
    						inf = "待审核";
    						break;
    			case 4:
    						inf = "待修改";
    						break;
    			case 5:
    						inf = "修改中";
    						break;
    			case 6:
    						inf = "已完成";
    						break;
    			case 7:
    						inf = "审核中";
    						break;
    			default:
    						inf = "未开始";
    						break;
    		}
    		return inf;
    		
    	}
    	//处理标题  超长后的长度变为...
    	function getTitle(title){
    		if(title.length >10){
    			 title = title.substr(0,10)+'...';
    		}
    			return title;
    		
    		
    	}
    	//处理类型  传入id 解析后返回土地或建筑
    	function getItemType(No){
    		var temp = No.substr(-5,1);
    		var type ='';
    		switch(temp){
    			case 'L':
	    			type = "土地";
	    			break;
	    		case 'B':
	    			type = '建筑';
	    			break;
	    		default:
	    			type = "其他";
	    			break
    		}
    		return type;
    	}
    	//校验权限控制按钮显示
    	function getButton(){
    		var btn = '';
    		var power = parent.powers;
    		if(power.has("0010")){  //查看按钮权限
    			 btn = btn +  '	<a class="btn btn-primary viewbtn" style="background-color: #FFEEBA;border: none;">查看</a>';
    		}
    		if(power.has("0005")){ //审核按钮权限
    			btn = btn + '<a class="btn btn-primary reviewbtn" style="background-color: #33ccff;border: none;margin-left: 5px;">审核 </a>';

    		}
    		if(power.has("0006")){
    			btn = btn + '<a class="btn btn-primary judgebtn" style="background-color: #33ff66;border: none;margin-left: 5px;">评估</a>';

    		}
              
    		return btn;
    	}
    	// 控制进度条
    	function getProgressBar(status){
					var bar = "";
    		switch(status){
    			

    						
    			case 5://驳回修改中  同评估中
    			case 2:
    						bar = '<div role="progressbar" style="width: 25%; height: 6px;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" class="progress-bar bg-red"></div>';
    						break;
    						
    			case 3://评估完成待审核
    						bar = '<div role="progressbar" style="width: 50%; height: 6px;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" class="progress-bar bg-violet"></div>';
    						break;
    			
    			case 7://审核中
    						bar = '<div role="progressbar" style="width: 75%; height: 6px;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" class="progress-bar bg-orange"></div>';
    						break;
    						
    			case 6://完成
    						bar = '<div role="progressbar" style="width: 100%; height: 6px;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" class="progress-bar bg-green"></div>';
    						break;
    						
    			case 1://已提交 保存状态 还未评估完成
    			case 4://审核驳回待修改 同未开始
    			default:
    						bar = '<div role="progressbar" style="width: 100%; height: 6px;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" class="progress-bar bg-gray"></div>';
    						break;
    		}
    		return bar;
    	}
    	
    	function bindBtnEvent(){
    		//评估按钮
    		$(".judgebtn").bind('click',function(){
    			var objid = $(this).parent().attr('objId') ;
    			var objName = $(this).parent().parent().parent().parent().find(".h4").html();
    			parent.addTabs("查看"+objName,"/judge_form.html?No="+objid,0,null);
    			
    		});
    		
    	}
    	
    	
    </script>
  </body>
</html>
